<template>
  <div class="app-container">
    <!-- 基本信息 -->
    <div class="titleLineGreen">基本信息</div>
    <div class="info flex">
      <el-image
        v-if="info"
        class="info_avatar"
        :src="info.workstationPic"
        :preview-src-list="[info.workstationPic]"
      ></el-image>
      <div class="info_right">
        <!-- 工作站信息 -->
        <div class="info_teacherinfos">
          <div class="flex info_teacherinfo_line1">
            <div class="info_teacherinfo_line_item flex">
              <el-tooltip
                class="item"
                effect="dark"
                :content="info.workstationName"
                placement="top-start"
              >
                <div class="info_teacherinfo_line_item_nickname overtxt">
                  {{ info.workstationName }}
                </div>
              </el-tooltip>
            </div>
            <div class="info_teacherinfo_line_item overtxt">
              工作站编号: {{ info.workstationNum }}
            </div>
          </div>
          <div class="flex info_teacherinfo_line2">
            <div
              class="info_teacherinfo_line1_rate info_teacherinfo_line_item flex"
            >
              <span>评分:</span>
              <el-rate disabled :value="info.workstationStar"></el-rate>
            </div>
            <div class="info_teacherinfo_line_item_short overtxt">
              负责人: {{ info.principalName }}
            </div>
            <div class="info_teacherinfo_line_item_short overtxt">
              可容纳人数: {{ info.stuNum }}
            </div>
            <el-tooltip
              class="item"
              effect="dark"
              :content="info.workstationAddress"
              placement="top-start"
            >
              <div class="info_teacherinfo_line_item_short overtxt">
                地址:
                {{ info.workstationAddress ? info.workstationAddress : "--" }}
              </div>
            </el-tooltip>
          </div>
          <div class="flex info_teacherinfo_associateACourse">
            关联课程:
            <div
              class="associateACourses flex"
              v-if="info.courseList && info.courseList.length > 0"
            >
              <div
                class="associateACourses_item"
                v-for="(item, index) in info.courseList"
                :key="index"
              >
                {{ item.course_name }}
              </div>
            </div>
            <div style="margin-bottom: 4px" v-else>--</div>
          </div>
          <div class="flex info_teacherinfo_courseIntro">
            工作站描述:
            <div class="courseIntro">
              {{ info.content ? info.content : "--" }}
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 评价 -->
    <div class="titleLineGreen" style="margin-top: 40px">评价</div>
    <el-form
      style="margin-top: 20px;width: 100%;"
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="80px"
    >
      <el-form-item label="学生" prop="name">
        <el-input
          v-input-restrict
          style="width: 150px"
          v-model="queryParams.name"
          placeholder="请输入学生名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班级" prop="classId">
        <el-select
          style="width: 150px"
          filterable
          v-model="queryParams.classId"
          placeholder="请选择"
          clearable
        >
          <el-option
            v-for="item in classes"
            :key="item.classId"
            :label="item.className"
            :value="item.classId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="评价" prop="evaluateStatus" v-show="showSearch">
        <el-input
          v-input-restrict-number
          style="width: 100px !important"
          :precision="0"
          @input="handleInputNumberChange1"
          :min="0"
          :max="5"
          controls-position="right"
          v-model="queryParams.minNum"
          placeholder=""
          clearable
          @keyup.enter.native="handleQuery"
        />
        至
        <el-input
          v-input-restrict-number
          @input="handleInputNumberChange2"
          :precision="0"
          style="width: 100px !important"
          :min="0"
          :max="5"
          controls-position="right"
          v-model="queryParams.maxNum"
          placeholder=""
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评价时间" prop="date" v-show="showSearch">
        <el-date-picker
          value-format="yyyy-MM-dd HH:mm:ss"
          v-model="queryParams.date"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="$pickerOptions"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          v-preventReClick
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button
          v-preventReClick
          icon="el-icon-refresh"
          size="mini"
          @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
      <right-toolbar
        style="margin-top: 3px"
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-form>
    <el-table v-loading="loading" :data="postList">
      <el-table-column label="学生" align="center" prop="name">
        <template slot-scope="scope">
          <div>{{ scope.row.name }}({{ scope.row.user_name }})</div>
        </template>
      </el-table-column>
      <el-table-column label="班级(学院-专业)" align="center" prop="class_name">
        <template slot-scope="scope">
          <div>
            {{ scope.row.class_name }}({{ scope.row.branch_name }}-{{
              scope.row.major_name
            }})
          </div>
        </template>
      </el-table-column>

      <el-table-column
        label="总分"
        align="center"
        prop="total"
        sortable
        width="165"
      >
        <template slot-scope="scope">
          <div style="text-align: left !important">
            <el-rate
              :value="scope.row.total"
              disabled
              show-score
              text-color="#ff9900"
              score-template="{value}"
            >
            </el-rate>
          </div>
        </template>
      </el-table-column>

      <el-table-column
        label="设备整齐"
        align="center"
        prop="equipment_star"
        sortable
        width="140"
      >
        <template slot-scope="scope">
          <div>
            <el-rate :value="scope.row.equipment_star" disabled> </el-rate>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="场地整洁"
        align="center"
        prop="env_star"
        sortable
        width="140"
      >
        <template slot-scope="scope">
          <div>
            <el-rate :value="scope.row.env_star" disabled> </el-rate>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="管理得当"
        align="center"
        prop="manager_star"
        sortable
        width="140"
      >
        <template slot-scope="scope">
          <div>
            <el-rate :value="scope.row.manager_star" disabled> </el-rate>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="评价时间"
        align="center"
        prop="student_evaluate_time"
      >
        <template slot-scope="scope">
          <div>
            {{ parseTime(scope.row.student_evaluate_time) }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            v-preventReClick
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleDetail(scope.row)"
            >详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <workstationDetailDia :open.sync="open" :item="item"></workstationDetailDia>
  </div>
</template>

<script>
import workstationDetailDia from "./components/workstationDetailDia";
import {
  getPost_workstation,
  workstationStuEvaluates,
} from "@/api/workstation/workstation";
import { listPost_class } from "@/api/schoolOrganization/organization";
export default {
  components: { workstationDetailDia },
  props: {},
  data() {
    return {
      open: false,
      item: {},
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 岗位表格数据
      postList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 9999,
        workstationId: undefined,
        classId: undefined,
        evaluateStatus: undefined,
        date: undefined,
        name: undefined,
        minNum: 0,
        maxNum: 5,
      },
      classes: [],
      info: {},
    };
  },
  watch: {},
  methods: {
    handleDetail(item) {
      this.open = true;
      this.item = item;
    },
    async getClasses() {
      let res = await listPost_class();
      this.classes = res.rows;
    },
    handleInputNumberChange1(value) {
      if (value > this.queryParams.maxNum) {
        this.$nextTick(() => {
          this.$set(this.queryParams, "minNum", this.queryParams.maxNum);
        });
      }
    },
    handleInputNumberChange2(value) {
      if (value < this.queryParams.minNum) {
        this.$nextTick(() => {
          this.$set(this.queryParams, "maxNum", this.queryParams.minNum);
        });
      }
    },
    /** 查询评价列表 */
    getList() {
      this.loading = true;
      this.queryParams.workstationId = this.$route.query.workstationId;
      this.queryParams.begin = this.queryParams.date
        ? this.queryParams.date[0]
        : "";
      this.queryParams.end = this.queryParams.date
        ? this.queryParams.date[1]
        : "";
      delete this.queryParams.date;
      workstationStuEvaluates(this.queryParams).then((response) => {
        this.postList = response.rows;
        this.loading = false;
      });
    },
    /* 查询工作站详细信息 */
    async getInfo() {
      let res = await getPost_workstation(this.$route.query.workstationId);
      this.info = res.data;
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.minNum = 0;
      this.queryParams.maxNum = 5;
      this.handleQuery();
    },
  },
  created() {},
  mounted() {
    this.getInfo();
    this.getClasses();
    this.getList();
  },
};
</script>
<style scoped lang="scss">
.info.flex {
  margin: 23px 0 0 0;
  .info_avatar {
    width: 120px;
    height: 64px;
    box-sizing: border-box;
    border: 1px solid rgba(229, 229, 229, 1);
    margin: 0 24px 0 10px;
  }

  .info_right {
    .info_teacherinfos {
      .info_teacherinfo_line1 {
        margin-top: 3px;
      }
      .info_teacherinfo_line2 {
        margin-top: 15px;
      }
      .info_teacherinfo_associateACourse {
        margin-top: 14px;
        font-size: 14px;
        font-weight: 400;
        line-height: 24px;
        color: rgba(96, 98, 102, 1);
        .associateACourses {
          margin-left: 6px;
          width: 705px;
          .associateACourses_item {
            margin: 0 0 8px 8px;
            padding: 0 12px;
            font-size: 14px;
            font-weight: 400;
            color: rgba(255, 255, 255, 1);
            height: 24px;
            opacity: 1;
            border-radius: 2px;
            line-height: 24px;
            background: rgba(39, 196, 120, 0.8);
          }
        }
      }
      .info_teacherinfo_courseIntro {
        margin-top: 8px;
        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
        color: rgba(96, 98, 102, 1);
        .courseIntro {
          word-wrap: break-word;
          width: 700px;
        }
      }
      .info_teacherinfo_line_item_short {
        box-sizing: border-box;
        padding-right: 25px;
        width: 200px;
        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
        color: rgba(96, 98, 102, 1);
      }
      .info_teacherinfo_line_item {
        box-sizing: border-box;
        padding-right: 25px;
        width: 276px;
        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
        color: rgba(96, 98, 102, 1);
        .info_teacherinfo_line_item_nickname {
          font-size: 18px;
          font-weight: 600;
          line-height: 20px;
          color: rgba(51, 51, 51, 1);
          max-width: 227px;
        }
        .sex {
          margin: 5px 0 0 5px;
          width: 12px;
          height: 12px;
        }
      }
    }

    .info_dataCards {
      margin-top: 22px;
      .info_dataCard {
        height: 112px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 1);
        box-shadow: 0px 0px 12px rgba(99, 99, 99, 0.14);
        box-sizing: border-box;
        padding: 16px 0 0 20px;
        .info_dataCard_topLine.flex {
          .info_dataCard_topLine_point {
            margin: 5px 8px 0 0;
            width: 10px;
            height: 10px;
            border-radius: 5px;
          }
          .info_dataCard_topLine_lable {
            font-size: 14px;
            font-weight: 600;
            line-height: 20px;
            color: rgba(51, 51, 51, 1);
            span {
              margin: 4px 0 0 0;
              font-size: 10px;
              font-weight: 400;
              line-height: 14px;
              color: rgba(51, 51, 51, 1);
            }
          }
        }
        .info_dataCard_dateLine2 {
          .info_dataCard_dateLine_item:last-of-type {
            width: 60px !important;
          }
        }
        .info_dataCard_dateLine1 {
          .info_dataCard_dateLine_item:last-of-type {
            width: 92px !important;
          }
        }
        .info_dataCard_dateLine.flex {
          margin-top: 20px;
          .info_dataCard_dateLine_item {
            width: 100px;
            .info_dataCard_dateLine_item_lable {
              font-size: 12px;
              font-weight: 400;
              line-height: 17px;
              color: rgba(153, 153, 153, 1);
            }

            .info_dataCard_dateLine_item_value {
              margin-top: 4px;
              font-size: 18px;
              font-weight: 600;
              line-height: 25px;
              color: rgba(238, 62, 62, 1);
              span {
                margin: 4px 0 0 0;
                font-size: 12px;
                font-weight: 400;
                line-height: 16px;
                color: rgba(51, 51, 51, 1);
              }
            }
          }
        }
      }
    }
  }
}
</style>
